using System.Collections.Generic;
using UniFramework.Actor;
using UniFramework.Aoe;
using UnityEngine;

namespace UniFramework.Battle
{
	public class BulletData
	{
		public static Dictionary<string, BulletOnCreate> onCreateFunc = new Dictionary<string, BulletOnCreate>()
		{
			{ "OnBulletCreateTest", OnBulletCreateTest }
		};

		public static Dictionary<string, BulletOnHit> onHitFunc = new Dictionary<string, BulletOnHit>()
		{
			{ "BulletOnHitTest", BulletOnHitTest }
		};

		public static Dictionary<string, BulletOnRemoved> onRemovedFunc = new Dictionary<string, BulletOnRemoved>()
		{
			{ "OnRemoveBulletTest", OnRemoveBulletTest },
			{ "OnRemoveBulletBeginAoe", OnRemoveBulletBeginAoe }
		};

		public static Dictionary<string, BulletTween> bulletTween = new Dictionary<string, BulletTween>()
		{
		};

		public static Dictionary<string, BulletTargetingFunction> targettingFunc =
			new Dictionary<string, BulletTargetingFunction>()
			{
			};

		private static void OnBulletCreateTest(LogicBullet bullet)
		{
			Debug.Log("OnBulletCreateTest");
		}

		private static void BulletOnHitTest(LogicBullet bullet, LogicObject target)
		{
			Debug.Log($"OnBulletOnHitTest,name:{target.name}");
		}

		private static void OnRemoveBulletTest(LogicBullet bullet)
		{
			Debug.Log($"OnRemoveBullet,name:{bullet.name}");
		}

		private static void OnRemoveBulletBeginAoe(LogicBullet bullet)
		{
			Debug.Log($"OnRemoveBulletBeginAoe,name:{bullet.name}");
			var main = GameObject.FindObjectOfType<GameMain>();
			var aoeSystem = main.aoeSystem;
			var aoeConfig = new AoeConfig("1", "AoeTest", null, 1, false, null, null, null, "OnChaEnterTest", "OnChaLeaveFunc",
				null, null);
			var aoeObj = new AoeObj(aoeConfig, bullet, bullet.LogicPos, 1, 1000, 0);
			if (bullet.BulletObj.hitCnt < bullet.BulletObj.config.cnaHitCnt)
				aoeSystem.CreateAoe(aoeObj);
		}
	}
}